package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
public class AppStarter {
    public static void main(String[] args) {
        SpringApplication.run(AppStarter.class, args);
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static class Demo {

        private RestTemplate restTemplate;
        public Object stocks(){
            Map<String,Object> mp =new HashMap<>();
            mp.put("api_name","daily");
            mp.put("token","531f7eda35d265a43c7091a5971802aab320a80c16afb6e7164c595a");
            Map<String,String> mp2 =new HashMap<>();
            mp2.put("ts_code","000002.SZ");
            mp2.put("start_date","19980101");
            mp2.put("end_date","20210903");
            // mp2.put();
            mp.put("params",mp2);

            // mp.put("fields","ts_code,name,area,industry,list_date");
            mp.put("Content-type","application/json;charset=utf8");
            Object responseVo = restTemplate.postForObject("http://api.waditu.com", mp, Object.class);
            //System.out.println(responseVo.getString("data"));

            return responseVo;//.getString("data");

        }

    }
}
